<form class="form-horizontal" role="form" method="post" enctype="multipart/form-data" action="<?php echo base_url().'work_facility/insert_parking';?>" />
<div class="container">
	<div class="col-md-offset-1">
		<div class="col-md-11">
			<div class="panel panel-default">
				<div class="panel-heading"><h4 class="panel-title"><b class="caret"></b><b> Request By</b></h4></div>
				<div class="panel-body">
					<div class="col-xs-12 col-md-6">
						<div class="form-group">
							<label class="control-label col-md-4">Name<span style="color:red;">*</span></label>
							<div class="col-md-7">
								<input type="text" class="select2 form-control input-sm" id="r_name" name="r_name" value="<?php echo $Emp_Name;?>">
								<input type="hidden" value="" id="r_nama" name="r_nama" class="select2 form-control input-sm" readonly="true"/>
							</div>
						</div>					
						<div class="form-group">
							<label class="control-label col-md-4">ID Number</label>
							<div class="col-md-3">
								<input type="text" class="form-control input-sm" id="r_id" name="r_id" value="<?php echo $Emp_Id;?>" readonly />
							</div>
						</div>
						<div class="form-group">
							<label class="control-label col-md-4">Manager</label>
							<div class="col-md-7">
								<input type="text" class="form-control input-sm" id="r_mgr" name="r_mgr" value="<?php echo set_value('Emp_Mgr');?>" readonly />
								<input type="hidden" value="" id="r_mgrid" name="r_mgrid" class="form-control input-sm" readonly="true"/>
							</div>
						</div>
						<div class="form-group">
							<label class="control-label col-md-4">Departement</label>
							<div class="col-md-7">
								<input type="text" class="form-control input-sm" id="r_dept" name="r_dept" value="<?php echo set_value('Emp_Dept');?>" readonly />
							</div>
						</div>						
					</div>
					<div class="col-sm-7 col-md-6">
						<div class="form-group">
							<label class="control-label col-md-4">Job Position</label>
							<div class="col-md-8">
								<input type="text" class="form-control input-sm" id="r_job" name="r_job" value="<?php echo set_value('Emp_Job');?>" readonly />
							</div>
						</div>
						<div class="form-group">
							<label class="control-label col-md-4">Work Status</label>
							<div class="col-md-5">
								<select name="pStatusFor" id="pStatusFor" onchange="change_status(this);" class="form-control input-sm">
									<option value="">-- select --</option>
									<option value="PERMANENT">PERMANENT</option>
									<option value="CONTRACT">CONTRACT</option>
								</select>
							</div>
						</div>
						<div class="form-group" id="date1" style="visibility:hidden;">
							<label class="control-label col-md-4">Period Date<span style="color:red;">*</span></label>
							<div class="col-md-6">
								<div class="input-group">
									<span class="input-group-addon"><small>From</small></span>
									<input type="text" class="form-control input-sm" autocomplete="off" name="G_Date2" id="G_Date2" value="<?php echo $dtNow?>">
								</div>
							</div>
						</div>
						<div class="form-group" id="date2" style="visibility:hidden;">
							<label class="control-label col-md-4"></label>
							<div class="col-md-6">
								<div class="input-group">
									<span class="input-group-addon"><small>To</small></span>
									<input type="text" class="form-control input-sm" autocomplete="off" name="G_Date3" id="G_Date3" value="<?php echo $dtNow?>">
								</div>
							</div>
						</div>
					</div>
				</div>
			</div>
			<div class="panel panel-default">
				<div class="panel-heading"><h4 class="panel-title"><b class="caret"></b><b> Form</b></h4></div>
				<div class="panel-body">
					<div class="col-sm-6 col-md-6">
						<div class="form-group">
							<label class="control-label col-md-2">Vehicle<span style="color:red;">*</span></label>
							<div class="col-md-10">
								<div class="radio"><label><input type="radio" id="vchoose1" name="v_car" onclick="CheckThis(1)" checked="checked"><label> Car</label></div>	
								<div class="table-responsive">
								<table class="table table-bordered table-condensed table-striped">
									<thead>
										<tr>
											<th class="tblhead" style="width:5%;text-align:center">No.</th>
											<th class="tblhead" style="width:25%;text-align:center">Vehicle License</th>
											<th class="tblhead" style="width:40%;text-align:center">Vehicle Number Certificate</th>
											<th class="tblhead" style="width:5%;text-align:center">Active</th>
										</tr>
									</thead>
									<tbody>
										<tr>
											<td style="text-align:center">1</td>
											<td>
												<input type="text" id="NoLcs1" class="form-control input-sm" name="NoLcs1" value="<?php echo set_value('License1');?>" 
												autocomplete="off"/>
											</td>
											<td>
												<input type="text" id="NoCert1" class="form-control input-sm" name="NoCert1" value="<?php echo set_value('Certificate1');?>" 
												autocomplete="off"/>
												</td>
											<td style="text-align:center"><input type="radio" id="NoRadio1" value="1" name="NoRadio1"/></td>
										</tr>
										<tr>
											<td style="text-align:center">2</td>
											<td>
												<input type="text" id="NoLcs2" class="form-control input-sm" name="NoLcs2" value="<?php echo set_value('License2');?>" 
												autocomplete="off"/>
											</td>
											<td>
												<input type="text" id="NoCert2" class="form-control input-sm" name="NoCert2" value="<?php echo set_value('Certificate2');?>" 
												autocomplete="off"/>
											</td>
											<td style="text-align:center"><input type="radio" id="NoRadio2" value="2" name="NoRadio2"/></td>
										</tr>
										<tr>
											<td style="text-align:center">3</td>
											<td>
												<input type="text" id="NoLcs3" class="form-control input-sm" name="NoLcs3" value="<?php echo set_value('License3');?>" 
												autocomplete="off"/>
											</td>
											<td>
												<input type="text" id="NoCert3" class="form-control input-sm" name="NoCert3" value="<?php echo set_value('Certificate3');?>" 
												autocomplete="off"/>
												</td>
											<td style="text-align:center"><input type="radio" id="NoRadio3" value="3" name="NoRadio3"/></td>
										</tr>
									</tbody>
								</table>
								</div>
							</div>
						</div>
					</div>
					<div class="col-sm-6 col-md-6">
						<div class="form-group">
							<div class="col-md-10">
								<div class="radio"><label>
                                <input type="radio" id="vchoose2" name="v_motor" onclick="CheckThis(2)">Motor</label></div>
								<div class="table-responsive">
								<table class="table table-bordered table-condensed table-striped">
									<thead>
										<tr>
										<th class="tblhead" style="width:5%;text-align:center">No.</th>
										<th class="tblhead" style="width:25%;text-align:center">Police Number</th>
										<th class="tblhead" style="width:40%;text-align:center">License Number</th>
										<th class="tblhead" style="width:5%;text-align:center">Active</th>
										</tr>
									</thead>
									<tbody>
										<tr>
										<td style="text-align:center">1</td>
										<td style="text-align:center"><input type="text" id="NoLcs4" name="NoLcs4" class="form-control input-sm" disabled /></td>
										<td style="text-align:center"><input type="text" id="NoCert4" name="NoCert4" class="form-control input-sm" disabled /></td>
										<td style="text-align:center"><input type="radio" id="NoRadio4" value="4" name="NoRadio4" disabled /></td>
										</tr>
									</tbody>
								</table>
								</div>
							</div>
						</div>
						<div class="form-group">
							<div class="col-md-9"><small><b>Vehicle License : <span>xx(spasi)1234(spasi)xxx</span></b></small></div>
							<div class="col-md-10">
								<small>
									<span style="color:#FF0000">xx </span>(1-2 Alphabet) 
									<span style="color:#FF0000">1234 </span>(1-4 Number) 
									<span style="color:#FF0000">xxx </span>(1-3 Alphabet)
								</small>
							</div>
						</div>
					</div>
					<div class="col-sm-6 col-md-7">
						<div class="form-group">
							<label class="control-label col-md-4">Description<span style="color:red;">*</span></label>
							<div class="col-md-7">
								<textarea name="Desc" id="Desc" class="form-control" rows="4"></textarea>
							</div>
						</div>
						<div class="form-group">
							<label class="control-label col-md-7">Upload Photo of License Number</label>
							<div class="col-md-5"><input type="file" id="file" name="file" class="control-label"/></div>
						</div>
					</div>
					<div class="col-md-11" style="margin-top:40px;">
						<div class="form-group" style="text-align:center">
							<div class="col-md-11">
								<input type="submit" value="Save This Form" name="submit" class="btn btn-md btn-success" onclick="return cekDulu(this)" />
							</div>
						</div>					
					</div>
				</div>
			</div>
		</div>
	</div>
</div>
</form>

<script>

function change_status(elm) 	
{
	var x = document.getElementById('date1');
	var y = document.getElementById('date2');
	
	if(elm.value=='CONTRACT'){
		x.style.visibility = 'visible';
		y.style.visibility = 'visible';	
	} 
	else 
	{
		x.style.visibility = 'hidden';
		y.style.visibility = 'hidden';		
	}
}

function CheckThis(VChoose)
{
	var i = 1;
	if(VChoose == '1')
	{
		for (i=1;i<4;i++)
		{
			var vc1 = document.getElementById('vchoose1');
			var Pol = document.getElementById('NoLcs'+i);
			var Stnk = document.getElementById('NoCert'+i);
			var Radio = document.getElementById('NoRadio'+i);
			Pol.disabled = false;Stnk.disabled = false;Radio.disabled = false;vc1.checked = true;
		}
		var vc2 = document.getElementById('vchoose2');
		var Pol = document.getElementById('NoLcs4');
		var Stnk = document.getElementById('NoCert4');
		var Radio = document.getElementById('NoRadio4');
		Pol.disabled = true;Stnk.disabled = true;Radio.disabled = true;vc2.checked = false;Radio.checked = false;
		Pol.value = '';Stnk.value = '';Radio.value = '';		
	}
	if(VChoose == '2')
	{
		for (i = 1;i<4;i++)
		{
			var vc1 = document.getElementById('vchoose1');
			var Pol = document.getElementById('NoLcs'+i);
			var Stnk = document.getElementById('NoCert'+i);
			var Radio = document.getElementById('NoRadio'+i);
			Pol.disabled = true;Stnk.disabled = true;Radio.disabled = true;vc1.checked=false;Radio.checked = false;
			Pol.value = '';Stnk.value = '';Radio.value = '';
		}
		var vc2 = document.getElementById('vchoose2');
		var Pol = document.getElementById('NoLcs4');
		var Stnk = document.getElementById('NoCert4');
		var Radio = document.getElementById('NoRadio4');
		Pol.disabled = false;Stnk.disabled = false;Radio.disabled = false;vc2.checked=true;
	} 
}

function cekDulu(elm)
{
	var frm = elm.form;
	
	$r_name = $('#r_name').val();
	if ($r_name=="-"){alert('Requestor tidak boleh kosong!'); document.getElementById('r_name').focus(); return false;}
	
	if (frm.elements['r_name'].value.length==0) {
		alert('Requestor tidak boleh kosong!');
		frm.elements['r_name'].focus();
		return false;
	}
	
	$pStatusFor = $('#pStatusFor').val();
	if ($pStatusFor==""){alert('Work Status tidak boleh kosong!'); document.getElementById('pStatusFor').focus(); return false;}
	
	if (frm.elements['vchoose1'].checked) {
		if (frm.elements['NoLcs1'].value.length==0 && frm.elements['NoLcs2'].value.length==0 && frm.elements['NoLcs3'].value.length==0) {
			frm.elements['NoLcs1'].focus();
			alert('Isi nomor kendaraan');
			return false;
		}
		if (!frm.elements['NoRadio1'].checked && !frm.elements['NoRadio2'].checked && !frm.elements['NoRadio3'].checked) {
			frm.elements['NoRadio1'].focus();
			alert('Pilih kendaraan aktif');
			return false;
		}
		if (frm.elements['NoRadio1'].checked && frm.elements['NoLcs1'].value.length==0 || frm.elements['NoRadio2'].checked && frm.elements['NoLcs2'].value.length==0 || frm.elements['NoRadio3'].checked && frm.elements['NoLcs3'].value.length==0) {
			alert('Kendaraan yang aktif harus isi');
			if (frm.elements['NoRadio1'].checked){frm.elements['NoLcs1'].focus();}
			if (frm.elements['NoRadio2'].checked){frm.elements['NoLcs2'].focus();}
			if (frm.elements['NoRadio3'].checked){frm.elements['NoLcs3'].focus();}
			return false;
		}
		
	} else if (frm.elements['NoLcs4'].value.length==0) {
		alert('Isi nomor kendaraan');
		return false;
	}
	
	if (frm.elements['Desc'].value.length==0) {
		alert('Description tidak boleh kosong!');
		frm.elements['Desc'].focus();
		return false;
	}
	
	if (frm.elements['file'].value.length==0) {
		alert('Pilih file untuk diupload');
		return false;
	}
		
}

</script>